<?php
namespace app\api\controller;

use app\common\model as M;


/**
 *
 */
class Bills extends \app\api\ApiAuth
{
    public $model = '\app\common\model\UserBill';

    /**
     * 金币账单
     * @Author   FW
     * @DateTime 2024-03-19
     * @Email    123763712@qq.com
     * @return   [type]           [description]
     */
    public function golds ()
    {
        $filter = input();
        $model = new M\user\UserGoldsBill();
        if ( isset($filter['stype']) && $filter['stype'] > 0 ) {
            $model->where('stype',$filter['stype']);
        }

        $records = $model->where('uid',$this->uid)
        ->order('create_time desc')
        ->page($filter['page'] ?? 1, $filter['limit'] ??  M\user\UserGoldsBill::LIMIT)
        ->select();

        if ( !empty($records) ) {
            $records = $records->toArray();

            foreach ( $records as &$record ) {
                $record['stype_display'] = M\user\UserGoldsBill::$stype[$record['stype']] ?? '-';
            }
        }
        return $this->returnSuccess($records);
    }
}//Class End